class Stack(object):
    def __init__(self):
        self.stack = []  # 创建一个空列表

    def push(self, elem):  # 出站
        self.stack.append(elem)

    def pop(self):
        return self.stack.pop()  # pop默认为-1，改成队列只需要pop（0）即可

    def emepy(self):
        return self.stack == []

    def top(self):
        if self.emepy():
            return "Stack is NONE"
        return self.stack[-1]

    def size(self):
        return len(self.stack)


class QueueCirculate(object):
    def __init__(self):
        self.maxsize = 5
        self.queue = []
        self.front = 0
        self.rear = 0

    def isfull(self):  # 判断full
        if (self.rear + 1) % self.maxsize == self.front:
            print("Queue is full")
            return True
        return False

    def isempty(self):
        if self.rear == self.front:
            return True
        return False

    def enqueue(self, elem):  # 入队
        if self.isfull():
            print('Enqueue error,queue is full')
            return
        self.queue.append(elem)
        self.rear = (self.rear + 1) % self.maxsize

    def dequeue(self):
        if self.isempty():
            print('Dequeue error,queue is empty')
            return
        self.front = (self.front + 1) % self.maxsize
        return (self.queue.pop(0))


if __name__ == '__main__':
    myqueue = QueueCirculate()
    myqueue.enqueue(1)
    myqueue.enqueue(2)
    myqueue.enqueue(3)
    print(myqueue.dequeue())
